package com.jie.client.service.ui.view;

import com.jie.client.core.ClientApplication;
import com.jie.client.service.entity.model.User;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.stage.Stage;

import java.util.List;
import java.util.Objects;

/**
 * 查看群用户的
 * @author XieZhiJie
 * @date 2022/04/29 13:40
 */
public class GroupUserView {

    private final List<User> userList;

    public GroupUserView(List<User> userList) {
        this.userList = userList;
    }

    public void createGroupUserView() {
        Stage stage = new Stage();
        TextArea text = new TextArea();
        text.setEditable(false);
        for (User user : this.userList) {
            text.appendText(user.getUsername() + "(" + user.getUserAccount() + ")");
            if (Objects.equals(user.getUserId(), ClientApplication.USER.getUserId())) {
                text.appendText("(我)");
            }
            text.appendText("\r\n");
        }
        Scene scene = new Scene(text, 300, 100);
        stage.setScene(scene);
        stage.setTitle("群聊成员");
        stage.show();
    }

}
